﻿using System.Web.Mvc;
using Library;

namespace Ecommerce.Controllers
{
    public class RedirectController : Controller
    {
        // GET: Redirect
        public ActionResult Index()
        {
            var routeCulture = RouteData.Values["culture"] != null ? RouteData.Values["culture"].ToString() : null;
            if (!string.IsNullOrEmpty(routeCulture) && RouteData.Values["redirecturl"] == null)
            {
                Response.Cookies.Remove("NOW.CurrentUICulture");
                return RedirectPermanent(Request.Url.ToString().Replace(routeCulture + "/", string.Empty).Replace(routeCulture, string.Empty));
            }
            return RedirectPermanent("~/" + RouteData.Values["redirecturl"]);
        }
    }
}